package tests;

import tester.*;

@Example
public class TestEquals {
	public TestEquals() {
	}

	@TestMethod
	public void testEquals(Tester t) {
		A test1 = new A();
		A test2 = new B();
		t.checkFail(test1, test2);
		t.checkFail(test2, test1);
	}
	
	private static void printEqual(A a1, A a2) {
		  if (a1.equals(a2)) {
		    System.out.println("EQUAL");
		  } else {
		    System.out.println("NOT-EQUAL");
		  }
	}
	
	public static void main(String[] args){
		A test1 = new A();
		A test2 = new B();
		printEqual(test1, test2);
		printEqual(test2, test1);
		//Tester.run(new TestEquals());
	}
}

class A {
	int n1;

	public A(){
		n1 = 4;
	}
	
	public boolean equals(Object o) {
		if (!(o instanceof A)) {
			return false;
		} else {
			A rhs = (A) o;
			return this.n1 == rhs.n1;
		}
	}
}

class B extends A { 
	  int n2;
	  public B(){
		  super();
		  n2 = 8;
	  }
	  public boolean equals(Object o) {
	    if (!(o instanceof B)) {
	      return false;
	    } else {
	      B rhs = (B)o;
	      return this.n1 == rhs.n1 && this.n2 == rhs.n2;
	    }
	  }
	}